import BaseAxios from "/@/common/CommonHttp";
import { $get, $post } from "/@/common/request";

/**
 * @author lhc
 * @description 订单类api
 * @date 2021-07-05
 */
class LoginApi extends BaseAxios<any, any> {
  constructor() {
    super("");
  }

  /**
   *  用户登录
   * @param param 传输的数据
   */
  public login(param: any): Promise<Base.IAxiosResponse<any>> {
    return this.axios.post("/ftUser/login", param);
  }

  /**
   *  用户登出
   * @param param 传输的数据
   */
  public logout(param: any): Promise<Base.IAxiosResponse<any>> {
    return this.axios.post("/cert/logout", param);
  }
}

export default LoginApi;

export const certLoginApi = ({ username, signature, message }) =>
  $post({
    url: "/login",
    params: { loginName: username, signature, message },
    parentUrl: "cert"
  });

export const getCertApi = (username: string) =>
  $get({
    url: "/cert",
    params: { loginName: username },
    parentUrl: "cert"
  });

export const getUserInfoApi = () =>
  $get({
    url: "/userinfo",
    params: {},
    parentUrl: "cert"
  });
